package com.py.androidUtils.UI.view;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.readyidu.app.R;

/**
 * @说明 清空消息记录
 * @作者 LY
 * @文件 ShowEmptyChatRecordView.java
 * @时间 2015年7月23日 上午8:49:11
 */
public class ShowEmptyChatRecordView {
	private Context mContext;

	public ShowEmptyChatRecordView(Context context) {
		this.mContext = context;
	}

	public void showView(View view) {
		View photosiew = LayoutInflater.from(mContext).inflate(R.layout.common_show_empty_chat_record, null);
		final PopupWindow popupWindow = new PopupWindow(photosiew, android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT);
		popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
		((TextView) photosiew.findViewById(R.id.btnCancel)).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				popupWindow.dismiss();
			}
		});
		((LinearLayout) photosiew.findViewById(R.id.line_bg)).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				popupWindow.dismiss();
			}
		});
		((TextView) photosiew.findViewById(R.id.emptyChatRecord)).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				emptyChatClickListener.emptyChat();
				popupWindow.dismiss();
			}
		});
	}

	public interface EmptyChatClickListener {
		void emptyChat();
	}

	private EmptyChatClickListener emptyChatClickListener;

	public void setEmptyChatClickListener(EmptyChatClickListener emptyChatClickListener) {
		this.emptyChatClickListener = emptyChatClickListener;
	}
}
